/*
 -------------------------------------------------------------------------------
 SerLCD.h
 
 Class description... .
 
 CONSTRUCTORS:
    SerLCD();    
 
 PUBLIC PROPERTIES:
    prop1 - description... .
    prop2 - description... .
 
 PUBLIC METHODS:
    type method1(type arg1);
        Description... .
            arg1 - description... .
 
 NOTES:
 
 
 EXAMPLES:
 
 Initially created by Cody Null on 9/9/11
 
 Modified by Jordan Hochenbaum on 12/5/11 (Version 1.5)
    http://arduino.cc/playground/Code/SerLCD
 
 Modified by Rowland O'Flaherty on 1/15/12 (Version 1.6)
 
 Version 1.6
 -------------------------------------------------------------------------------
 */

#ifndef _SerLCD_h_
#define _SerLCD_h_

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <Arduino.h>
#include <SoftwareSerial.h>

class SerLCD : public SoftwareSerial {
    
public:
    //--------------------------------------------------------------------------
    // Constants, Enums, and Types
    //--------------------------------------------------------------------------
	
    
    //--------------------------------------------------------------------------
    // Lifecycle
    //--------------------------------------------------------------------------
    
    // Constructors
    SerLCD();
	SerLCD(int pin);
    
    // Destructor
    virtual ~SerLCD();
    
    // Copy constructor
    //SerLCD(const SerLCD& srcObj);
    
    // Assignment operator
    const SerLCD& operator=(const SerLCD& rhsObj);

    //--------------------------------------------------------------------------
    // Overloaded Operators
    //--------------------------------------------------------------------------
    
    
    //--------------------------------------------------------------------------
    // Public Member Functions
    //--------------------------------------------------------------------------
	void clear();
	void clearLine(int);
	void home();
	void setBrightness(int);

	void setSplash();
	void toggleSplash();

	void blink();
	void noBlink();
	void cursor();
	void noCursor();
	void display();
	void noDisplay();

	void setCursor(int, int);
	void selectLine(int);

	void leftToRight();
	void rightToLeft();
	void autoscroll();
	void noAutoscroll();

	void createChar(int, uint8_t[]);
	void printCustomChar(int);
    
    
    //--------------------------------------------------------------------------
    // Public Member Variables
    //--------------------------------------------------------------------------
    
    

private:
    //--------------------------------------------------------------------------
    // Constants, Enums, and Types
    //--------------------------------------------------------------------------
    // Commands
    static const uint8_t LCD_BACKLIGHT =        0x80;
    static const uint8_t LCD_CLEARDISPLAY =     0x01;
    static const uint8_t LCD_CURSORSHIFT =      0x10;
    static const uint8_t LCD_DISPLAYCONTROL =   0x08;
    static const uint8_t LCD_ENTRYMODESET =     0x04;
    static const uint8_t LCD_FUNCTIONSET =      0x20;
    static const uint8_t LCD_SETCGRAMADDR =     0x40;
    static const uint8_t LCD_SETDDRAMADDR =     0x80;
    static const uint8_t LCD_SETSPLASHSCREEN =  0x0A;
    static const uint8_t LCD_SPLASHTOGGLE =     0x09;
    static const uint8_t LCD_RETURNHOME =       0x02;

    // Flags for display entry mode
    static const uint8_t LCD_ENTRYRIGHT =       0x00;
    static const uint8_t LCD_ENTRYLEFT =        0x02;

    // Flags for display on/off control
    static const uint8_t LCD_BLINKON =          0x01;
    static const uint8_t LCD_CURSORON =         0x02;
    static const uint8_t LCD_DISPLAYON =        0x04;

    // Flags for display size
    static const uint8_t LCD_2LINE =            0x02;
    static const uint8_t LCD_4LINE =            0x04;
    static const uint8_t LCD_16CHAR =           0x10;
    static const uint8_t LCD_20CHAR =           0x14;

    //  Flags for setting display size
    static const uint8_t LCD_SET2LINE =         0x06;
    static const uint8_t LCD_SET4LINE =         0x05;
    static const uint8_t LCD_SET16CHAR =        0x04;
    static const uint8_t LCD_SET20CHAR =        0x03;
    
	//--------------------------------------------------------------------------
    // Lifecycle
    //--------------------------------------------------------------------------
    void copyHelper(const SerLCD& srcObj);
    
    //--------------------------------------------------------------------------
    // Private Member Functions
    //--------------------------------------------------------------------------
    void command(uint8_t);
	void specialCommand(uint8_t);
    
    //--------------------------------------------------------------------------
    // Private Member Variables
    //--------------------------------------------------------------------------
	uint8_t _displayfunction;
	uint8_t _displaycontrol;
	uint8_t _displaymode;
	uint8_t _numlines;
	uint8_t _numchars;
	uint8_t _rowoffset;
};

#endif